/*
 * Copyright (c) 2022-2022 All rights Reserved.
 */

package com.driving.core.util;

import lombok.Getter;
import lombok.NonNull;

/**
 * 系统所用常量值
 *
 * @author SAGITTAR
 * @since 2017
 */
public class Constant {

    /**
     * 姓名（昵称）
     */
    public static final String NAME = "name";

    /**
     * 身份令牌
     */
    public static final String TOKEN = "Token";

    /**
     * 用户ID
     */
    public static final String ID = "id";

    /**
     * 手机号
     */
    public static final String MOBILE = "mobile";

    /**
     * 密码
     */
    public static final String PASSWORD = "password";

    /**
     * 身份角色
     */
    public static final String AUDIENCE = "audience";

    private Constant() {
        throw new Error();
    }

    /**
     * 习题状态
     *
     * @author SAGITTAR
     */
    public static class ExerciseStatus {

        /**
         * 未删除
         */
        public static final int NOT_DELETED = 1;
        /**
         * 已删除
         */
        public static final int DELETED = 0;

        private ExerciseStatus() {
            throw new Error();
        }
    }

    /**
     * 添加类型，1为错题，2为收藏
     *
     * @author SAGITTAR
     */
    public static class ExerciseType {

        /**
         * 错题
         */
        public static final int INCORRECT = 1;

        /**
         * 收藏
         */
        public static final int COLLECTION = 2;

        private ExerciseType() {
            throw new Error();
        }
    }

    /**
     * 系统角色
     */
    @Getter
    public enum Audience {

        /**
         * 学员
         */
        STUDENT("Student"),

        /**
         * 教练
         */
        COACH("Coach"),

        /**
         * 管理员
         */
        ADMIN("Admin");

        private final String audience;

        Audience(String audience) {
            this.audience = audience;
        }

        /**
         * 由字符串描述获取身份类型
         *
         * @param audience 字符串描述
         * @return 由字符串描述获取身份类型
         */
        public static Audience from(@NonNull String audience) {
            Audience result = null;
            for (Audience current : values()) {
                if (current.getAudience().equalsIgnoreCase(audience)) {
                    result = current;
                    break;
                }
            }
            return result;
        }

        @Override
        public String toString() {
            return audience;
        }
    }
}
